import request from '@/utils/request'
import request3 from '@/utils/request3'

import { formatDate3 } from "@/utils"

// 分时数据
export function getfenshishuju(targetDate) {
  const data = {
    targetDate
  }
  return request({
    url: "api/v1/backend/face/time/sharing",
    method: "post",
    data
  });
}

// 编辑小目标
export function getTargetInfo(marketId, date){
  const data = {
    marketId, date
  }
  return request({
    url: "api/v2/backend/target/info",
    method: "post",
    data
  });
}
export function getTargetSave(marketId, date, marketTargetId,personNumber,orderAmount){
  const data = {
    marketId, date, marketTargetId,personNumber,orderAmount
  }
  return request({
    url: "api/v2/backend/target/action",
    method: "post",
    data
  });
}

// 总数据看板 123
export function getTradingData(date) {
  const data = {
    date
  }
  return request({
    url: 'api/v1/backend/getChainMarkDataUpdate',
    method: 'post',
    data
  })
}

// 总数据看板 4
export function getPeopleCountData(date) {
  const data = {
    date
  }
  return request({
    url: 'api/v1/backend/read_sense/face/chang_rate',
    method: 'post',
    data
  })
}

// 获取市场每日销量
export function fetchMarketDailySales(id, year, month, day){
  const formData = new FormData()
  formData.append('id', id)
  formData.append('year', year)
  formData.append('month', month)
  formData.append('day', day)
  const data = formData
  return request3({
    url: '/aggs/market/dailySales',
    method: 'post',
    data
  })
}

// 获取市场每日6大类销售数据
export function fetchMarketDailyTopType(id, year, month, day) {
  const formData = new FormData()
  formData.append('id', id)
  formData.append('year', year)
  formData.append('month', month)
  formData.append('day', day)
  const data = formData
  return request3({
    url: 'aggs/market/dailyTopType',
    method: 'post',
    data
  })
}

// 获取市场每日热销
export function fetchMarketDailyHostSales(id, year, month, day, sort) {
  const formData = new FormData()
  formData.append('id', id)
  formData.append('year', year)
  formData.append('month', month)
  formData.append('day', day)
  formData.append('sort', sort)
  const data = formData
  return request3({
    url: 'aggs/market/dailyHostSales',
    method: 'post',
    data
  })
}

// 获取市场每日交易排行
// sort 1：金额，3：交易笔数
export function fetchMarketDailyBusinessTop10(id, year, month, day, sort){
  const formData = new FormData()
  formData.append('id', id)
  formData.append('year', year)
  formData.append('month', month)
  formData.append('day', day)
  formData.append('sort', sort)
  const data = formData
  return request3({
    url: 'aggs/market/dailyBusinessTopTen',
    method: 'post',
    data
  })
}

// 获取市场月度销售数据
export function fetchMarketMonthlySales(id, year, month){
  const formData = new FormData()
  formData.append('id', id)
  formData.append('year', year)
  formData.append('month', month)
  const data = formData
  return request3({
    url: '/aggs/market/monthlySales',
    method: 'post',
    data
  })
}

// 获取市场每日到访间隔
export function fetchMarketDailyVisitInterval(targetDate) {
  const data = {targetDate}
  return request({
    url: 'api/v1/backend/face/visit/interval',
    method: 'post',
    data
  })
}

export function fetchMarketDailyCheckInfo(date) {
  const data = {date}
  return request({
    url: 'api/v2/backend/check/total',
    method: 'post',
    data
  })
}

// 获取市场每日客流漏斗
export function fetchMarketDailyFlowFunnel(targetDate) {
  const data = {targetDate}
  return request({
    url: 'api/v1/backend/face/flow/funnel',
    method: 'post',
    data
  })
}

export function fetchMarketMontlyFlowTrend(year, month) {
  const data = {year, month}
  return request({
    url: 'api/v1/backend/face/total/month/flow_count',
    method: 'post',
    data
  })
}

export function fetchMarketDailyFaceAgeHour(year, month) {
  const data = {year, month}
  return request({
    url: 'api/v1/backend/face/month/age_hour',
    method: 'post',
    data
  })
}

// 分时数据 金额
export function getChartLineBarNew(year, month, day, id) {
  const formData = new FormData()
  formData.append('id', id)
  formData.append('year', year)
  formData.append('month', month)
  formData.append('day', day)
  const data = formData
  return request3({
    url: 'aggs/market/hourlyHistogram',
    method: 'post',
    data
  })
}
// 分时 电子支付 笔数 和 金额
export function getChartLineBarEpayNew(year, month, day, id) {
  const formData = new FormData()
  formData.append('id', id)
  formData.append('year', year)
  formData.append('month', month)
  formData.append('day', day)
  const data = formData
  return request3({
    url: 'aggs/market/hourlyHistogram/epay',
    method: 'post',
    data
  })
}

// 20200303

// 分时数据
export function getChartLineBar(date) {
  const data = {
    date
  }
  return request({
    url: 'api/v1/backend/getChainMarkLineChartUpdate',
    method: 'post',
    data
  })
}

// 检测信息
export function getCheckReportData(startDate, perPage, page) {
  const data = {
    startDate, perPage, page
  }
  return request({
    url: 'api/v1/backend/check_report',
    method: 'post',
    data
  })
}

// 20200303

// 六大类占比数据
export function getSixTypeDataNew(marketId) {
  const data = {
    marketId
  }
  return request({
    url: 'api/v7/market_statistics/market_sale_amount_by_business_type',
    method: 'post',
    data
  })
}

// 20200303

// 六大类占比数据
export function getSixTypeData(date) {
  const data = {
    date
  }
  return request({
    url: 'api/v1/backend/marketBusinessTypeSaleAmount',
    method: 'post',
    data
  })
}

// 获取南京天气数据
export function getNJWeather(date) {
  const data = {
    date
  }
  return request({
    url: 'api/v1/backend/getWeather',
    method: 'post',
    data
  })
}
